<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
             //父构造函数
             function Fn(name,age){
            this.name = name
            this.age = age
        }
        //给父类构造函数原型添加属性
        Fn.prototype.sin = function(){
            console.log('只因你太美');
        }
        //子级构造函数
          function Son(name,age){
             Fn.call(this,name,age)
          }
        //将父级的构造函数挂载到子级原型的指向上,不影响子级和父级之间的原型
          Son.prototype.__proto__ = Fn.prototype
          //子级构造函数原型挂载方法
          Son.prototype.tex = function(){
            console.log('考试');
          }
         const c = new Son('cxk',20)
         const f = new Fn('zs',3)
         console.log(c);
         console.log(c.sin());
         console.log(f);
         console.log(f.tex());
    </script>
</body>
</html>